package com.gainsoft.grevocabuilder;

import android.app.Activity;
import android.content.res.Resources;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;

public class VocaBuilder extends Activity
{
    /** Called when the activity is first created. */
    @SuppressWarnings("unchecked")
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	Spinner spinner = (Spinner) findViewById(R.id.alphabets);

	@SuppressWarnings("rawtypes")
	ArrayAdapter<CharSequence> adapter = new ArrayAdapter(this,
		android.R.layout.simple_spinner_item, getResources()
			.getStringArray(R.array.alphabets))
	{
	    @Override
	    public View getDropDownView(int position, View convertView,
		    ViewGroup parent)
	    {
		Resources res = getResources();
		View view = super
			.getDropDownView(position, convertView, parent);
		if (position % 2 == 0)
		{
		    view.setBackgroundColor(res.getColor(R.color.altrow));
		} else
		{
		    view.setBackgroundColor(res.getColor(R.color.row));
		}

		return view;
	    }

	};
	TextView tx = (TextView) findViewById(R.id.textView1);
	Word.mContext = getApplicationContext();
	Cursor c = Word.getWordCursorByAlphabet("a");
	c.moveToFirst();
	tx.setText(c.getString(c.getColumnIndex(Word.WORD_COL)));
	spinner.setAdapter(adapter);

    }
}